1bashThis demonstrates using sed to perform a global search and replace in a file.sed 's/fox/bear/g' foo.txtexternal toolssedsearch and replace
2bashThis demonstrates using sed to perform in-place text replacement in a file.sed 's/fox/bear/g' foo.txt --in-placeexternal toolssedin-place text replacement
3bashExtract the word "lazy" from the sentence "The quick brown fox jumps over the lazy dog." using sed. This demonstrates how to use sed to capture and print a specific part of a string based on a pattern.echo "The quick brown fox jumps over the lazy dog." | sed -n "s|.*the \(.*\) dog.*|\1|p"external toolssed
4bashThis demonstrates using sed for find-and-replace operations in text files.sed 's/fox/bear/g' foo.txt > bar.txtexternal toolssedfind-and-replace operations
5bashThis demonstrates using sed to perform a global search and replace operation within a file.sed 's/red fox/blue bear/g' foo.txtexternal toolssedtext replacement (global search and replace)
6bashThis code uses sed to extract and manipulate a substring from the input string. It captures the word before "dog" and prints a modified sentence: "What is the dog? lazy". This demonstrates pattern matching and substitution using sed.echo "The quick brown fox jumps over the lazy dog." | sed -n "s|.*the \(.*\) dog.*|What is the dog? \1|p"external toolssed
7bashThis demonstrates using sed to find and replace patterns in a string using regular expressions.echo "abc123def456" | sed -E 's/[a-z]*/First letters ==> & <== /'external toolssedregex substitution (regular expression substitution)
8bashThis demonstrates pattern matching and extraction using sed in Bash.echo "The quick brown fox jumps over the lazy dog." | sed -n "s|.*\(the .* dog\).*|\1|p"external toolssedpattern matching and extraction
9bashThis demonstrates pattern matching and substitution using sed with a custom delimiter.echo "The quick brown fox jumps over the lazy dog." | sed -n "s|the \(.*\) dog|something else|p"external toolssedpattern matching and substitution
10bashThis demonstrates using sed for case-insensitive text replacement in a file.sed 's/fox/bear/gi' foo.txtexternal toolssedin-file text replacement
11bashThis demonstrates basic text substitution using sed.echo "The quick brown fox" | sed 's/brown/red/' #Result: The quick red foxexternal toolssedtext substitution (simple)
12bashThis script replaces every occurrence of the string okay with great in file.txt using sed, with the -i flag modifying the file in place.sed -i 's/okay/great/g' file.txt # be aware that this -i flag means that file.txt will be changed # -i or --in-place erase the input file (use --in-place=.backup to keep a back-up)external toolssed
13bashThis demonstrates basic string substitution using sed to replace the first occurrence of a pattern in a string.echo "Hello, hello, hello" | sed 's/hello/goodbye/' #Result: Hello, goodbye, helloexternal toolssedstring substitution